package com.qingzhuge.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import static com.qingzhuge.common.Constants.DEFAULT_ENCODING;

/**
 * @author : zero.xiao
 * @description :
 * @date :2018/8/8 0008 下午 16:00
 * @since : 1.0.0
 * @modified :
 */
public class URLEncodeUtil {
    /**
     * URL 解码
     */
    public static String getURLDecoderString(String str) {
        String result = "";
        if (null == str) {
            return result;
        }
        try {
            result = URLDecoder.decode(str, DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
    /**
     * URL 转码
     */
    public static String getURLEncoderString(String str) {
        String result = "";
        if (null == str) {
            return result;
        }
        try {
            result = URLEncoder.encode(str, DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
}